function ajax(url) {
    return new Promise(function (resolve, reject) {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", url);
        xhr.responseType = "json";
        xhr.onload = function () {
            if (this.status === 200) {
                resolve(this.response);
            } else {
                reject(new Error(this.statusText));
            }
        };
        xhr.send();
    });
}
ajax("/api/users.json")
    .then((res) => {
        console.log(res);
    })
    .catch((err) => {
        console.log(err);
    });

Promise.resolve(1).then(2).then(Promise.resolve(3)).then(console.log);
